package com.yue.controller;

import com.yue.domain.User;
import com.yue.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/user")

public class UserController {
    @Autowired
    private UserService userService;
    @GetMapping(value = "/getUser")
    public User getUser(@RequestParam String name){
        User user = userService.findByName(name);
        return user;
    }
    @PostMapping(value = "/addUser")
    public User addUser(){
        User user = userService.addUser();
        return user;
    }
    @PostMapping(value = "/deleteUser")
    public User deleteUser(@RequestBody User user){
        userService.deleteUser(user.getName());
        return user;
    }
}
